﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using RouterControl.Db;
using RouterControl.Web;

internal static class RouterControlWS2ExtensionMethods
{
    public static DeviceDomDbConnector.ErrorInfo ToDatabase(this ErrorInfo ei)
    {
        return new DeviceDomDbConnector.ErrorInfo()
        {
            InstanceId = new Guid(ei.InstanceGuid),
            ReleaseId = ei.VersionId,
            TimeStampUtc = ei.TimeStampUtc,
            Count = ei.Count,

            ErrorType = ei.ErrorType,
            Message = ei.Message,
            ClassName = ei.ClassName,
            MethodName = ei.MethodName,
            StackTrace = ei.StackTrace,
            ErrorHash = ei.ErrorHash,

            Inner = (ei.Inner == null ? null : ei.Inner.ToDatabase())
        };
    }

    public static DeviceDomDbConnector.ReleaseInfo ToDatabase(this ReleaseInfo ei)
    {
        return new DeviceDomDbConnector.ReleaseInfo()
        {
            ReleaseId = ei.ReleaseId,
            VersionStr = ei.VersionStr,
            ReleaseUrl = ei.ReleaseUrl,
            MsiDownloadUrl = ei.MsiDownloadUrl
        };
    }
}
